<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>商品信息</title>
</head>
<body>
    <h1>后台</h1>
    <h2>商品信息</h2>
    <div>
        <p>商品名称：<span id="name"></span></p>
        <p>商品编号：<span id="code"></span></p>
        <p>商品价格：<span id="price"></span></p>
        <p>商品标识：<span id="tag"></span></p>

    </div>

<script th:src="@{/js/jquery-3.6.0.js}"></script>
<script th:src="@{/js/axios.min.js}"></script>
<script th:src="@{/js/common.js}"></script>
<script>
    const code = "1000"; // 测试商品编号
    $(document).ready(queryProduct);

    function queryProduct() {
        const url = API["productData"];
        const params = {code: code};
        get(url, params, function(result) {
            if (result.code == RESULT_OK) {
                const data = result.data;
                $("#name").text(data.name);
                $("#code").text(data.code);
                $("#price").text((data.price/100).toFixed(2));
                $("#tag").text(data.tag);
            }
        })
    }
</script>
</body>
</html>